# -*- coding: utf-8 -*-

import sys
from PyQt5 import QtCore
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class MainWindow(QWidget):

    def __init__(self):
        super(MainWindow, self).__init__()

        self.setGeometry(100, 100, 400, 350)
        self.setWindowTitle("Calendar示例")

        self.cal = QCalendarWidget(self)
        self.cal.setMinimumDate(QDate(1980, 1, 1))
        self.cal.setMaximumDate(QDate(3000, 1, 1))
        self.cal.setGridVisible(True)
        self.cal.move(20, 20)
        self.cal.clicked[QtCore.QDate].connect(self.show_date)

        self.lb1 = QLabel(self)
        date = self.cal.selectedDate()
        self.lb1.setText(date.toString("yyyy-MM-dd dddd"))
        self.lb1.move(20, 300)

    def show_date(self, date):
        self.lb1.setText(date.toString("yyyy-MM-dd dddd"))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    sys.exit(app.exec())